package org.esky;

/**
 * 编写一个线程类，启动10条线程同时执行该类，要求输出效果如下所示： 001 002 …… …… 998 999
 */
import java.text.NumberFormat;

public class T1 {

	public static void main(String[] args) {
		RunnableA a = new RunnableA();
		for (int i = 0; i < 10; i++) {
			new Thread(a).start();
		}
	}
}

// 创建线程A  
class RunnableA implements Runnable {
	NumberFormat format = NumberFormat.getNumberInstance();

	private  int i = 1;
	
	public synchronized void run() {
		format.setMinimumIntegerDigits(3);
		while (i < 1000) {
			System.out.println(format.format(i));
			i++;
			try {
				Thread.sleep(10);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
